package com.chanel.iamframework.core.service;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

import com.chanel.iamframework.core.domain.Application;
import com.chanel.iamframework.validation.annotation.Validate;

@Validate
public interface ApplicationService {

	
	/**
	 * Persist Application entity
	 * @param application entity
	 */
	void createApplication(@NotNull @Valid Application application);
	
	/**
	 * Get Application by id
	 * @param applicationId Identity
	 * @return Application entity
	 */
	Application getApplication(@NotNull Long applicationId);

	/**
	 * Update Application entity
	 * @param application entity
	 * @return true if the object is persisted, false otherwise.
	 */
    boolean updateApplication(@NotNull @Valid Application application);
    
    /**
     * Delete application by identity
     * @param applicationId identity
     * @return true if the object is persisted, false otherwise.
     */
    boolean deleteApplication(@NotNull Long applicationId);

    /**
     * Load Groups by applicationId into the returned {@link com.chanel.iamframework.core.domain.Application} instance.
     * @param applicationId identity
     * @return {@link com.chanel.iamframework.core.domain.Application} instance with list of {@link com.chanel.iamframework.core.domain.Group}
     */
	Application loadGroups(@NotNull Long applicationId);

	/**
	 * Load Roles by applicationId into the returned {@link com.chanel.iamframework.core.domain.Application} instance.
	 * @param applicationId identity
	 * @return {@link com.chanel.iamframework.core.domain.Application} instance with list of {@link com.chanel.iamframework.core.domain.Role}
	 */
	Application loadRoles(@NotNull Long applicationId);

	/**
	 * Load User by applicationId into the returned {@link com.chanel.iamframework.core.domain.Application} instance.
	 * @param applicationId identity
	 * @return {@link com.chanel.iamframework.core.domain.Application} instance with list of {@link com.chanel.iamframework.core.domain.User}
	 */
	Application loadUsers(@NotNull Long applicationId);

	/**
	 * Add Application, Groups association.
	 * @param application entity containing list of {@link com.chanel.iamframework.core.domain.Group}.
	 */
	void addGroups(@NotNull Application application);

	/**
	 * Delete Application, Groups association
	 * @param application entity containing list of {@link com.chanel.iamframework.core.domain.Group}.
	 * @return true if {@link Application#getGroups()} list changed as a result of the call
	 */
	boolean deleteGroups(@NotNull Application application);
}
